import { Entity, PrimaryGeneratedColumn, Column } from "typeorm";
import { ManualTimestamp } from "../decorators/manual-timestamp.decorator";

@Entity("announcements")
@ManualTimestamp()
export class AnnouncementEntity {
  @PrimaryGeneratedColumn({
    comment: "公告ID" })
  id!: number;

  @Column("varchar", {
    length: 200,
    comment: "公告标题" })
  title!: string;

  @Column("text", {
    comment: "公告内容" })
  content!: string;

  @Column("int", {
    default: 1,
    comment: "公告状态：1-草稿，2-已发布，3-已下线" })
  state!: number;

  @Column("int", {
    default: 0,
    comment: "公告优先级：0-普通，1-重要，2-紧急" })
  priority!: number;

  @Column("varchar", {
    length: 100,
    nullable: true,
    comment: "发布者" })
  publisher?: string;

  @Column("datetime", {
    comment: "发布时间" })
  publishTime!: Date;

  @Column("datetime", {
    nullable: true,
    comment: "下线时间" })
  offlineTime?: Date;

  @Column("int", {
    default: 0,
    comment: "浏览次数" })
  viewCount!: number;

  @Column("int", {
    default: 1,
    comment: "是否激活：1-激活，0-禁用" })
  isActive!: number;

  @Column("datetime", { name: "created_at", comment: "创建时间" })
  created_at!: Date;
@Column("datetime", { name: "updated_at", nullable: true, comment: "更新时间" })
  updated_at!: Date | null;
}
